<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>20210902124邵文杰</title>

    <script src="node_modules\vue\dist\vue.js"></script>
    <style>
        .basic {
            width: 100px;
            height: 100px;
        }

        .skyblue-bg {
            background-color: skyblue;
        }

        .yellow-bg {
            background-color: khaki;
        }

        .pink-bg {
            background-color: pink;
        }

        .border-radius {
            border-radius: 50%;
        }

        .border10 {
            border: 10px solid red;
        }
    </style>
</head>

<body>
    <div id="app">
        <select v-model="selectedStyle">
            <option value="skyblue-bg">skyblue</option>
            <option value="yellow-bg">yellow</option>
            <option value="pink-bg">pink</option>
        </select>
        <div :class="[computedStyle, 'basic']"></div>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                selectedStyle: ''
            },
            computed: {
                computedStyle: function () {
                    if (this.selectedStyle === 'skyblue-bg') {
                        return 'skyblue-bg border-radius';
                    } else if (this.selectedStyle === 'yellow-bg') {
                        return 'yellow-bg border10';
                    } else if (this.selectedStyle === 'pink-bg') {
                        return 'pink-bg';
                    }
                    return '';
                }
            }
        });
    </script>
</body>

</html>